package com.ib.algokit.forex;

import static org.activequant.util.tools.IdentityUtils.equalsTo;
import static org.activequant.util.tools.IdentityUtils.safeCompare;
import static org.activequant.util.tools.IdentityUtils.safeHashCode;

import java.io.Serializable;

/**
 * ChangeDetails  implements Comparable&lt;ChangeDetails&gt;<br/>
 * Holds the following associated variables:
 * <ul>
 * <li>forexPair(String)</li>
 * <li>change(Change)</li>
 * <li>slowBidValue(double)</li>
 * <li>fastBidValue(double)</li>
 * </ul>
 * @author Dimitar
 *
 */
public class ChangeDetails implements Comparable<ChangeDetails>, Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * final private String forexPair;
	 */
	final private String forexPair;
	/**
	 * final private Change change;
	 */
//	final private Change change;
	/**
	 * final private double slowBidValue;
	 */
	final private double slowBidValue;
	/**
	 * final private double fastBidValue;
	 */
	final private double fastBidValue;
	/**
	 * final private double percChange;
	 */
	final private double percChange;
	
//	public Change getChange() {
//		return change;
//	}

	public double getSlowBidValue() {
		return slowBidValue;
	}

	public double getFastBidValue() {
		return fastBidValue;
	}
	
	public double getPercChange() {
		return percChange;
	}
	
	public String getForexPair() {
		return forexPair;
	}
	
	public ChangeDetails(String forexPair, double slowBidValue, double fastBidValue, double percChange) {
		this.forexPair = forexPair;
//		this.change = change;
		this.slowBidValue = slowBidValue;
		this.fastBidValue = fastBidValue;
		this.percChange=percChange;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object other) {
		// NOTE: delegates to compareTo()
		return equalsTo(this, other);
	}
	/**
	 * {@inheritDoc}
	 */
	public int compareTo(ChangeDetails other) {
		// ATTENTION: keep in sync with hashCode();
		int rc;		
		rc = safeCompare(this.forexPair, other.forexPair);
		return rc;
	}
	/**
	 * {@inheritDoc}
	 */
	public int hashCode() {
		// ATTENTION: keep in sync with compareTo()
		return safeHashCode(this.forexPair);
	}
	
    @Override
    public String toString() {
		String ret= forexPair==null?"":(forexPair+"\t");
//		ret += change==null?"":(change+"\t");
		ret += percChange==0?"":(percChange+ "\t");
		ret += slowBidValue==0?"":(slowBidValue+ "\t");
		ret += fastBidValue==0?"":(fastBidValue);
		return ret;
	}
}
